package com.sf.hackathons.app.presenter.impl;


import com.sf.hackathons.app.bean.StoreDetailBean;
import com.sf.hackathons.app.helper.GroupDetailHelper;
import com.sf.hackathons.app.presenter.constract.MainConstract;
import com.sf.hackathons.lib.commui.base.BasePresenterImpl;
import com.sf.hackathons.lib.http.ICallBack;
import com.sf.hackathons.lib.utils.GsonUtils;

/**
 * Created by guofanghua on 2017/9/20.
 */
public class MainPresenter extends BasePresenterImpl<MainConstract.View> implements MainConstract.Presenter {


    @Override
    public void loadHttpDetail() {
        getView().showProgress();
        GroupDetailHelper mGroupDetailHelper = new GroupDetailHelper();
        mGroupDetailHelper.setCallback(new ICallBack() {
            @Override
            public void onSuccess(int taskId, String result) {
                StoreDetailBean mStoreDetailBean = GsonUtils.json2Bean(result, StoreDetailBean.class);
                getView().dismissProgress();
                getView().loadDetailSuccess(mStoreDetailBean);
            }

            @Override
            public void onFailed(int taskId, String errorCode, String msg) {
                getView().dismissProgress();
                getView().loadDetailFail(errorCode, msg);

            }
        });
        mGroupDetailHelper.sendHttpRequest();
    }
}